package cn.edu.ldk.controller;

import cn.edu.ldk.common.CommonJsonResult;
import cn.edu.ldk.pojo.Address;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
public class ConsultController {
//    public static final String PROVIDER_URL="http://localhost:8003/provider/";
    public static final String SERVER_URL="http://consul-provider-service/";

    //注入RestTemplate对象
    @Autowired
    private RestTemplate restTemplate;


    //根据id查询数据
    @GetMapping("/consul/consumer/getAddressinfo")
    public CommonJsonResult<Address> getAddinfosById(){
        CommonJsonResult commonJsonResult
                = restTemplate.getForObject(SERVER_URL + "consul/getAddress", CommonJsonResult.class);
            return commonJsonResult;
    }

}
